import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:short_drama/pages/login/login.dart';
import 'package:short_drama/pages/main_tabs/main_tab.dart';
import 'package:short_drama/utils/global_util.dart';

void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  await initApp();
  runApp(const MyApp());
}

Future<void> initApp() async {
  SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
      statusBarColor: Colors.transparent,
      statusBarIconBrightness: Brightness.dark,
      systemNavigationBarColor: Colors.black,
      systemNavigationBarIconBrightness: Brightness.light
  ));
  await GlobalUtil.initGlobal();
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: GlobalUtil.hasLogin() ? const MainTabPage() : const LoginPage(),
      builder: EasyLoading.init(),
      defaultTransition: Transition.cupertino,
    );
  }
}